package com.udf.hive.udf.uuid;

import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.hive.ql.udf.UDFType;
import org.apache.hadoop.io.Text;

import java.util.UUID;
import java.util.logging.Logger;

/**
 * 生成uuid随机数
 * 
 * @author weixiaozhong
 * @version [版本号, 2021年1月14日]
 */
@UDFType(deterministic = false)
public class getUuidUDF extends UDF
{
    private static Logger logger = Logger.getLogger("getUuidUDF");

    public Text evaluate() {

        String uuid = UUID.randomUUID().toString();

        return new Text(uuid);
    }

    public static void main(String[] args) {
        logger.info(String.valueOf(new getUuidUDF().evaluate()));
    }

}
